version: '3.8'

#Docker Networks
networks:
  laravel:
    driver: bridge

#Volumes
volumes:
  dbdata:
    driver: local

# Workflow
services:
  nginx:
    build:
      context: ./docker-compose/nginx
      args:
        WORKDIR: ${WORKDIR_INTERNAL:?Need workdir}
    container_name: ${CONTAINER_PREFIX:?Need prefix}-nginx
    ports:
      - "8080:80"
      # - "4430:443"
      # Port for xdebug (ensure this matches the remote_port in the xdebug.ini)
      # - "9011:9011"
    volumes:
      - /home/httpd:/home/zepedro/:delegated
    depends_on:
      - php
      - mysql
    networks:
      - laravel

  mysql:
    image: mysql:8.0.26
    container_name: ${CONTAINER_PREFIX}-mysql
    restart: unless-stopped
    tty: true
    ports:
      - "3316:3306"
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME} 
      MYSQL_PASSWORD: ${DB_PASSWORD} 
      SERVICE_TAGS: dev
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql/
    networks:
      - laravel

  # redis:
  #   image: "redis:alpine"
  #   container_name: ${CONTAINER_PREFIX}-redis
  #   restart: unless-stopped
  #   ports:
  #     - "6389:6379"
  #   networks:
  #     - laravel

  php:
    build:
      context: ./docker-compose/php
      args:
        WORKDIR: ${WORKDIR_INTERNAL}
    container_name: ${CONTAINER_PREFIX}-php
    volumes:
      - /home/httpd:${WORKDIR_INTERNAL}:delegated
      # Enable xdebug
      #- ./docker-compose/php/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
    ports:
      - "9010:9010"
    networks:
      - laravel
